package com.binyouwei.customize_compose_view.histogram

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.example.base_model.weight.MyTopBar

class BarChartActivity : ComponentActivity() {
    @OptIn(ExperimentalMaterial3Api::class)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            Scaffold(topBar = {
                MyTopBar(title = "柱状图", onClickAction = { finish() })
            }) { paddingValues ->
                val data =
                    remember {
                        listOf(
                            HistogramData("1月", 10f),
                            HistogramData("2月", 25f),
                            HistogramData("3月", 20f),
                            HistogramData("4月", 58f),
                            HistogramData("5月", 25f),
                            HistogramData("6月", 45f),
                            HistogramData("7月", 97f),
                            HistogramData("8月", 55f),
                            HistogramData("9月", 32f),
                            HistogramData("10月", 68f),
                            HistogramData("11月", 88f),
                            HistogramData("12月", 16f)
                        )
                    }
                Histogram(
                    data,
                    Modifier
                        .width(400.dp)
                        .height(400.dp)
                        .padding(paddingValues)
                )
            }
        }
    }
}